﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System.ComponentModel;


public partial class Instrument
{
    /// <summary>
    /// 获取所有乐器信息
    /// </summary>
    /// <returns></returns>
    public DataTable GetInstruments()
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetInstruments();
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获取某一个分类的所有乐器
    /// </summary>
    /// <param name="CategoryID"></param>
    /// <returns></returns>
    public DataTable GetInstrumentByCategory(int CategoryID)
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetInstrumentByCategory(CategoryID);
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获取某一乐器的信息
    /// </summary>
    /// <param name="BookID"></param>
    /// <returns></returns>
    public DataTable GetSingleInstrument(int instruID)
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetSingleInstrument(instruID);
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获取乐器种类数量
    /// </summary>
    /// <returns></returns>
    public int GetInstumentKindQuantity()
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetInstruKindQuantity();
        int num = 0;
        foreach (var v in result)
        {
            num = (int)v.InstruKinds;
        }
        return num;
    }
    /// <summary>
    /// 获取最新乐器
    /// </summary>
    /// <returns></returns>
    public DataTable GetNewest()
    {
        DataTable table = GetInstruments();
        return table;
    }
    /// <summary>
    /// 获取最热乐器
    /// </summary>
    /// <returns></returns>
    public DataTable GetHotest()
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetHotestInstru();
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获取推荐乐器
    /// </summary>
    /// <returns></returns>
    public DataTable GetRecommend()
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetRecommendInstru();
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
}
